/******************************************************************************
 * SAGE - Scalable Adaptive Graphics Environment
 *
 * Module: fsServer.h
 * Author : Byungil Jeong
 *
 * Copyright (C) 2004 Electronic Visualization Laboratory,
 * University of Illinois at Chicago
 *
 * This library is free software; you can redistribute it and/or modify it
 * under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either Version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
 * License for more details.
 *
 * You should have received a copy of the GNU Lesser Public License along
 * with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 *
 * Direct questions, comments etc about SAGE to bijeong@evl.uic.edu or 
 * http://www.evl.uic.edu/cavern/forum/
 *
 *****************************************************************************/
 

#ifndef _FS_SERVER_H
#define _FS_SERVER_H

#include "sage.h"
#include <QUANTA/QUANTA.hxx> 
#include <QUANTA/QUANTAnet_tcp_c.hxx>

#define SOCK_BUF_SIZE (1024*1024*32)
#define READ_BUF_SIZE 4096
#define SYSTEM_CLIENT_BASE 1000

class fsManager;

class fsServer {
private:
	QUANTAnet_tcpServer_c *sysServer;
	QUANTAnet_tcpServer_c *uiServer;
	QUANTAnet_udp_c *trackingServer;
	
	fsManager *fsm;
	std::vector<QUANTAnet_tcpClient_c *> uiClientList;
	std::vector<QUANTAnet_tcpClient_c *> sysClientList;
	int numSysClients, numUiClients;

public:
	fsServer();
	~fsServer();
	int init(fsManager *fsm);
	static void* trackingThread(void *args);
	int checkTrackingMsg();
	int checkClients();
	int sendMessage(int cId, int code, int data);
	int sendMessage(int cId, int code, char* data);
	int sendMessage(int cId, int code);	
	int sendMessage(sageMessage &msg);
};

#endif
